<template>
  <div>
    <div class="container mx-auto">
      <div v-for="item in categorys" :key="item.id">
        <div class="categorysItem">
          <div>
            {{ item.title }}
          </div>
          <button @click="goAnswers(item.id)">进入</button>
        </div>
      </div>
      <div class="categorysRight">哈哈哈</div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
const { data: tiList } = await useFetch(
  "http://47.113.230.113:8088/question/categorys"
);
const categorys = tiList.value.data.categorys;
const goAnswers = (id) => {
  router.push({
    path: "/answers",
    query: {
      id: id,
    },
  });
};
</script>

<style lang="scss" scoped>
.categorysItem {
  width: 80%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: bold;
  background-color: #fff;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-radius: 15px;
  margin: 15px 0;
  display: flex;
  button {
    border: 0;
    width: 80px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease; /* 平滑过渡所有属性变化 */

    &:hover {
      background-color: #0f89e5;
      color: #fff;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* 水平偏移 垂直偏移 模糊半径 颜色 */
      transform: translateY(-2px); /* 轻微上浮增强交互感 */
    }
  }
}
.categorysRight {
  width: 18%;
  height: 50%;
  background-color: #fff;
  position: fixed;
  border-radius: 15px;
  right: 75px;
  top: 80px;
}
</style>
